﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using FuturamaKassa.Objects;

namespace FuturamaKassa.Commands.ReceiveCommands {
    class CreateInventory : ReceiveCommand {

        public override void Execute(List<byte> response) {

            response.RemoveRange(0, 6);
            response.RemoveRange(response.Count - 2, 2);

            string check = Encoding.ASCII.GetString(new byte[] { response[0], response[1] });
            string sizeHex = Encoding.ASCII.GetString(new byte[] { response[2], response[3], response[4], response[5] });
            
            if (check.Equals("00")) {

                int sizeInt = int.Parse(sizeHex, NumberStyles.AllowHexSpecifier);

                Inventory.GetInstance().Size = sizeInt;
                Logger.Instance.writeLog("Command Create Inventory(6C20) executed");
            } else {
                Logger.Instance.writeLog("ERROR: Command Create Inventory(6C20) could not execute. " + check);
            }
        }
    }
}
